﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Drawing;

namespace nStruct
{

	public class ENG_Struct
	{
		public bool MODE;//true, flase
		public int Group;
		public int ModuleNo;
		public int ChannelNo;
		public float Volt;
		public float Current;
		public int OnOff;
	}

	
	public class File_Infor_Struct
	{
		public string fPath;
		public string fName;
	}
	public class Com_Conf_Struct
	{
		public string[] PortName = new string[8];
		public int[] Speed = new int[8];
		public int[] Status = new int[8];
		public bool DeviceOK;
		public bool ReceiveOK =false;

        public string[] PS_Conf_FileName = new string[3];
	}
	public class Setup_Group
	{
		public int GROUP = 0;
	}
	public class Select_Struct
	{
		public int PS_Group;
		public int PS_CH;
		public int PS_HW_CH;
		public int Temp_Group;
		public int Temp_Channel;
	}
	public class PS_Conf_Struct
	{
		//File
		public string FullFileName = "";
		public string FolderName = "";
		public string FileName = "";

		public string LogFolder = "";
		public string LogFileName = "";
		public bool LogFileExist=false;
		
		//Select
		public int SelectItem = 0;//0->PS, 1->Temp
		public int PsSelectCh = 0;
		public int TempSelectCh = 0;
		
		//operation
		public int START;

		//ps Set
		public float VsetMaster;
		public float IsetMaster;
		public float IProtect_Master;
		public int PsNo;

		public int[] PsEn = new int[40];
		public float[] Vset = new float[40];
		public float[] Iset = new float[40];
		public int[] StringNo = new int[40];
		public String[] PsName = new String[40];
		public float[] IProtect = new float[40];

		//temp Set
		public int TempNo;
		public int[] TempEn = new int[16];
		public string[] TempName = new string[16];
		public byte TempProtectMaster;
		public byte[] TempProtect = new byte[16];


		//Reading Data
		public int[] Temp_Status = new int[16];
		public byte[] Temp_Value = new byte[16];

		//Hardware PS 기준 Data
		public int HW_No;
		public int[] HW_PsEn = new int[40];
		public int[] HW_PsStringIndex = new int[40];
		public int[] HW_PsID = new int[40];
		public String[] HW_PsName = new String[40];
		public float[] HW_IProtect = new float[40];

		public int[] HW_I_Status = new int[40];
		public float[] HW_I_Value = new float[40];

		public void Calc_HW_Data(PS_Conf_Struct inDat)
		{
			int no = 0;
			for (int i = 0; i < inDat.PsNo; i++)
			{
				if (inDat.StringNo[i] == 1)
				{

					inDat.HW_PsName[no] = inDat.PsName[i];
					inDat.HW_PsStringIndex[no] = 0;
					inDat.HW_PsEn[no] = inDat.PsEn[i];
					inDat.HW_PsID[no] = i;
					inDat.HW_IProtect[no] = inDat.IProtect[i];
					no++;
				}
				else
				{
					for (int j = 0; j < inDat.StringNo[i]; j++)
					{
						inDat.HW_PsName[no] = inDat.PsName[i] + "-" + (j + 1).ToString();
						inDat.HW_PsStringIndex[no] = j;
						inDat.HW_PsEn[no] = inDat.PsEn[i];
						inDat.HW_PsID[no] = i;
						inDat.HW_IProtect[no] = inDat.IProtect[i];
						no++;
					}
				}
			}
			
			inDat.HW_No = no;
			for (int i = no; i < 40; i++)
			{
				inDat.HW_PsName[i] = "";
				inDat.HW_PsStringIndex[i] = 0;
				inDat.HW_PsEn[i] = 0;
				inDat.HW_PsID[i] = 0;
				inDat.HW_IProtect[i] = 0;
			}
		}
		
	}


	
}